﻿using System;
using System.BLL;
using System.Collections.Generic;
using System.Dto;
using System.IBLL;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace System.MVC.Controllers
{
    /// <summary>
    /// 监控管理控制器
    /// </summary>
    public class MonitorSystemController : Controller
    {
        /// <summary>
        /// 监控大屏页面
        /// </summary>
        /// <returns></returns>
        public ActionResult MonitoringInfoList()
        {
            ViewBag.userDer = Session["DepartMentId"].ToString();
            return View();
        }
        /// <summary>
        /// 监控大屏页面table数据请求接口
        /// </summary>
        /// <param name="limit">条数</param>
        /// <param name="page">页数</param>
        /// <param name="monitorName">监控器名</param>
        /// <param name="monitoringArea">监控地区</param>
        /// <returns></returns>
        public JsonResult GetMonitoringInfoList(int limit, int page, string monitorName, string monitoringArea)
        {
            IParkingManager manager = new ParkingManager();
            int datalet;
            var data = manager.getMonitoringListDtos(limit, page, out datalet, monitorName, monitoringArea);
            return Json(new { code = 0, msg = "获取成功", count = datalet, data = data }, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 添加监控器信息页面
        /// </summary>
        /// <returns></returns>
        public ActionResult AddMonitoringInfo()
        {
            return View();
        }
        /// <summary>
        /// 添加监控器信息页面业务请求接口
        /// </summary>
        /// <param name="listDto">数据模型</param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult AddMonitoringInfo(GetMonitoringListDto listDto)
        {
            IParkingManager manager = new ParkingManager();
            manager.AddNewOneMonitoringInfo(listDto);
            return Json(new { code = 0, msg = "添加成功" });
        }
        /// <summary>
        /// 监控大屏页面table删除按钮业务请求接口
        /// </summary>
        /// <param name="id">监控器ID</param>
        /// <returns></returns>
        public JsonResult DelMonitoringInfo(int id)
        {
            IParkingManager manager = new ParkingManager();
            manager.DelMonitoringInfoById(id);
            return Json(new { code = 0, msg = "删除成功" }, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 监控器信息修改页面
        /// </summary>
        /// <param name="id">监控器ID</param>
        /// <returns></returns>
        public ActionResult EditMonitoringInfo(int id)
        {
            IParkingManager manager = new ParkingManager();
            var data = manager.getOneMonitoringById(id);
            return View(data);
        }
        /// <summary>
        /// 监控器信息修改页面业务请求接口
        /// </summary>
        /// <param name="listDto">数据模型</param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult EditMonitoringInfo(GetMonitoringListDto listDto)
        {
            IParkingManager manager = new ParkingManager();
            manager.EditOneMonitoringByDto(listDto);
            return Json(new { code = 0, msg = "修改成功" });
        }

        /// <summary>
        /// 视频信息管理页面
        /// </summary>
        /// <returns></returns>
        public ActionResult SurveillanceVideoList() 
        {
            IParkingManager manager = new ParkingManager();
            var data = manager.getVideoDepositLists();
            ViewBag.data = data;
            return View();
        }
        /// <summary>
        /// 视频信息管理页面table数据获取接口
        /// </summary>
        /// <param name="limit">条数</param>
        /// <param name="page">页数</param>
        /// <param name="depositId">位置ID</param>
        /// <param name="videoName">视频名</param>
        /// <returns></returns>
        public JsonResult GetSurveillanceVideoList(int limit, int page, string depositId, string videoName)
        {
            IParkingManager manager = new ParkingManager();
            int datalet;
            var data = manager.GetVideoDepositToSurveillanceVideoLists(limit, page, out datalet, videoName, depositId);
            return Json(new { code = 0, msg = "获取成功", count = datalet, data = data }, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 添加存放区的页面
        /// </summary>
        /// <returns></returns>
        public ActionResult AddVideoDeposit()
        {
            return View();
        }
        /// <summary>
        /// 添加存放区页面的按钮业务请求接口
        /// </summary>
        /// <param name="dto">数据模型</param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult AddVideoDeposit(VideoDepositToSurveillanceVideoDto dto)
        {
            IParkingManager manager = new ParkingManager();
            manager.AddNewOneVideoDeposit(dto);
            return Json(new { code = 0, mag = "添加成功" });
        }
        /// <summary>
        /// 视频信息编辑页面
        /// </summary>
        /// <param name="id">视频信息ID</param>
        /// <returns></returns>
        public ActionResult EditSurveillanceVideo(int id)
        {
            IParkingManager manager = new ParkingManager();
            var list = manager.GetVideoDepositToSurveillance(id);
            return View(list);
        }
        /// <summary>
        /// 视频信息编辑页面修改按钮业务请求接口
        /// </summary>
        /// <param name="dto">数据模型</param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult EditSurveillanceVideo(VideoDepositToSurveillanceVideoDto dto)
        {
            IParkingManager manager = new ParkingManager();
            manager.EditOneSurveillanceVideoByDto(dto);
            return Json(new { code = 0, msg = "修改成功" });
        }
        /// <summary>
        /// 视频信息页面table删除按钮业务请求接口
        /// </summary>
        /// <param name="id">视频信息ID</param>
        /// <returns></returns>
        public JsonResult DelSurveillanceVideo(int id)
        {
            IParkingManager manager = new ParkingManager();
            manager.DelOneSurveillanceVideoById(id);
            return Json(new { code = 0, msg = "删除成功" }, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 移动视频页面
        /// </summary>
        /// <param name="id">视频ID</param>
        /// <returns></returns>
        public ActionResult MoveSurveillanceVideo(int id)
        {
            IParkingManager manager = new ParkingManager();
            var list = manager.GetVideoDepositToSurveillance(id);
            var data = manager.getVideoDepositLists();
            ViewBag.data = data;
            return View(list);
        }
        /// <summary>
        /// 移动视频页面业务请求接口
        /// </summary>
        /// <param name="dto">数据模型</param>
        /// <returns></returns>
        [HttpPost]
        public JsonResult MoveSurveillanceVideo(VideoDepositToSurveillanceVideoDto dto)
        {
            IParkingManager manager = new ParkingManager();
            manager.EditOneSurveillanceVideoByDto(dto);
            return Json(new { code = 0, msg = "移动成功" });
        }

        public ActionResult ReadSurveillanceVideo(int id)
        {
            ViewBag.videoUrl = "http://localhost:7391/Content/layui-ckplayer-master/example/video_resource.mp4";
            return View();
        }

        [HttpGet]
        public JsonResult text()
        {
            string data = "Content/layui-ckplayer-master/example/video_resource.mp4";
            return Json(new { code = 0, data = data }, JsonRequestBehavior.AllowGet);
        }

        public ActionResult VideoCheck()
        {
            return View();
        }

    }
}